package structural.flyweight.demo;

import java.util.HashMap;
import java.util.Map;

public class ChesspieceFactory {
	
	private static Map<String,Chesspiece> pool = new HashMap<String,Chesspiece>();
	
	public static Chesspiece getChesspiece(String color){
		Chesspiece chesspiece = pool.get(color);
		if(chesspiece == null){
			chesspiece = new ConcreteChesspiece(color);
			pool.put(color, chesspiece);
		}
		return chesspiece;
	}
}
